@extends('layouts.admin')

@section('title', '编辑管理员')

@section('content')
    <div id="pad-wrapper" class="new-user">
        <div class="row header">
            <div class="col-md-12">
                <h3>编辑管理员</h3>
            </div>
        </div>
        @if (count($errors) > 0)
            <div class="alert alert-danger">
                <ul>
                    @foreach ($errors->all() as $error)
                        <li>{{ $error }}</li>
                    @endforeach
                </ul>
            </div>
        @endif
        <div class="row form-wrapper">
            <!-- left column -->
            <div class="col-md-9 with-sidebar">
                <form class="form-horizontal" role="form" method="post" action="/admin/admin_users/{{$admin_user->id}}"
                      enctype="multipart/form-data">
                    <input type="hidden" name="_method" value="PUT">
                    <div class="form-group">
                        <label for="inputPhone1" class="col-md-2 control-label">登录名</label>
                        <div class="col-md-8">
                            <input type="text" name="name" class="form-control" value="{{$admin_user->name}}">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="inputPhone1" class="col-md-2 control-label">邮箱</label>
                        <div class="col-md-8">
                            <input type="text" name="email" class="form-control" value="{{$admin_user->email}}">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="inputPhone1" class="col-md-2 control-label">密码</label>
                        <div class="col-md-8">
                            <input type="text" name="password" class="form-control">
                            <br>
                            <span class="label label-danger">注：如果不需要修改密码，则不需要填写</span>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="inputPhone1" class="col-md-2 control-label">角色</label>
                        <div class="col-md-8">
                            @foreach(\App\Models\AdminRole::where('id','>',1)->get() as $role)
                                <input type="checkbox" name="role_ids[]" value="{{$role->id}}" @if(in_array($role->id,$my_role_ids)) checked @endif>
                                <span class="label label-default">{{$role->title}}</span>
                            @endforeach
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-md-offset-2 col-md-8">
                            <button type="submit" class="btn btn-primary">保存</button>
                        </div>
                    </div>
                </form>
            </div>

        </div>
    </div>
@endsection